package com.sunshine.student_register.database.register;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

/**
 * @author sunshine
 * @date 2020/5/30
 * 学生签到操作
 */

@Dao
public interface RegisterDao {

    //查找
    @Query("SELECT * FROM RegisterEntity")
    List<RegisterEntity> getAllRegister();

    //获取指定用户id的所有签到记录
    @Query("SELECT * FROM REGISTERENTITY WHERE studentId=:userId")
    List<RegisterEntity> getThisUserAllRegister(int userId);

    //插入
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertRegister(RegisterEntity registerEntity);

    //修改
    @Update
    void updateRegister(RegisterEntity registerEntity);

    //删除
    @Delete
    void deleteRegister(RegisterEntity registerEntity);

    //删除全部
    @Query("DELETE FROM RegisterEntity WHERE 1=1")
    void deleteAllRegister();
}
